package com.bwei.like.mynewstop.app;

import android.app.Application;
import android.content.Context;
<<<<<<< 77331352d74e6afdfbbeaccca4370d33ffbea935
import android.os.Handler;
import android.os.Process;

=======
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Process;
import android.view.ViewGroup;

import com.bwei.like.mynewstop.R;
import com.bwei.like.mynewstop.utils.CommonUtils;
>>>>>>> NewsTop
import com.bwei.like.mynewstop.utils.ImageLoaderUtils;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import org.xutils.x;

<<<<<<< 77331352d74e6afdfbbeaccca4370d33ffbea935
=======
import java.util.HashMap;
>>>>>>> NewsTop
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import cn.smssdk.EventHandler;
import cn.smssdk.SMSSDK;

/**
 * Created by LiKe on 2016/10/31.
 */
public class MyApplication extends Application {

    private static Context context;
    private static Handler handler;
    private static int mainThreadId;
    private static Thread currentThread;
    private static ExecutorService executorService;
    public static boolean showChnanelLongListener = false;

<<<<<<< 77331352d74e6afdfbbeaccca4370d33ffbea935
=======
    //设置夜间模式的静态变量
    public static boolean isNightMode = false;
    private static HashMap<Integer, Integer> reourseMap;
    private static Context applicationContext;
>>>>>>> NewsTop

    @Override
    public void onCreate() {
        super.onCreate();
        //获取上下文
        context = getApplicationContext();
        //获取handler
        handler = new Handler();
        //获取主线程id
        mainThreadId = Process.myTid();
        //获取当前线程
        currentThread = Thread.currentThread();
        //创建线程池
        executorService = Executors.newFixedThreadPool(5);
        //初始化Xutils
        x.Ext.init(this);
        //设置debug模式
        x.Ext.setDebug(true);
        ImageLoaderUtils.initConfiguration(getApplicationContext());

        //短信
<<<<<<< 77331352d74e6afdfbbeaccca4370d33ffbea935

=======
>>>>>>> NewsTop
        SMSSDK.initSDK(this, "18cbdd7ac1644", "e9679e8eb23efbd950d6900b0e59edad");

        //QQ
        PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
        PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad");
        UMShareAPI.get(this);
<<<<<<< 77331352d74e6afdfbbeaccca4370d33ffbea935
    }

=======
        applicationContext = this.getApplicationContext();

        isNightMode = CommonUtils.getBooleanFlag("isnightMode");

    }
   public static void saveNightMode(){
       CommonUtils.saveBoolean("isnightMode",isNightMode);
   }
>>>>>>> NewsTop
    public static ExecutorService getThreadPoll() {
        return executorService;
    }

<<<<<<< 77331352d74e6afdfbbeaccca4370d33ffbea935
    public static Thread getMainThread(){
        return currentThread;
    }

    public static int getMainThreadId(){
        return mainThreadId;
    }

    public static Handler getHandler(){
        return handler;
    }

    public static Context getContext(){
        return context;
    }
=======
    public static Thread getMainThread() {
        return currentThread;
    }

    public static int getMainThreadId() {
        return mainThreadId;
    }

    public static Handler getHandler() {
        return handler;
    }

    public static Context getContext() {
        return context;
    }

    public static Drawable getResouseDrawable(int resId){
        Drawable drawable = applicationContext.getResources().getDrawable(getResouseId(resId));
        return drawable;
    }


    public static int getResouseId(int resId) {
        if (reourseMap == null) {
            initNightMap();
        }
        if (isNightMode) {
            return reourseMap.get(resId);
        } else {
            return resId;
        }
    }


    //初始化图片资源
    public static void initNightMap() {
        reourseMap = new HashMap<>();
        reourseMap.put(R.drawable.cell_phone_selector, R.drawable.cellphone_leftdrawer_pressed_night);
        reourseMap.put(R.drawable.qq_leftdrawer_selector, R.drawable.qq_leftdrawer_normal_night);
        reourseMap.put(R.drawable.sina_leftdrawer_selector, R.drawable.sina_leftdrawer_normal_night);
        reourseMap.put(R.drawable.download_drawer_selector, R.drawable.downloadicon_leftdrawer_normal_night);
        reourseMap.put(R.drawable.night_drawer_selector, R.drawable.nighticon_leftdrawer_normal_night);
        reourseMap.put(R.drawable.settings_drawer_selector, R.drawable.settingicon_leftdrawer_normal_night);
        reourseMap.put(R.color.BLACK,R.color.WHITE);
    }
>>>>>>> NewsTop
}
